import { defineStore } from 'pinia';

import { toggleTheme } from '@/utils/index';

type State = {
  loading: boolean,
  currentDate: number,
  device: string,
  [key: string]: any
}

export const useAppStore = defineStore('_app', {
  state: (): State => ({
    loading: false,
    currentDate: new Date().getTime(),
    device: 'desktop',
  }),
  actions: {
    setLoadingStatus(status: boolean) {
      console.log('status::', status);

      this.loading = status;
    },
    setDevice(device: string) {
      this.device = device;
    },
    setCurrentDate(date: number) {
      this.currentDate = date;
    },

    changeTheme: toggleTheme,
  },
});
